/**
 * Created by suweiming on 2017/12/30.
 */
function jsonToQueryStr(json) {
    var tmp = [];
    Object.keys(json).map(item => {
        tmp.push(`${item}=${json[item]}`)
    });
    return tmp.join('&');
}
function assign(...json) {
    return Object.assign({}, ...json);
}
import Icon from 'react-native-vector-icons/Ionicons';
import Feather from 'react-native-vector-icons/Feather';
import Foundation from 'react-native-vector-icons/Foundation';
import forge from 'node-forge';// 加密功能
/**
 *  md5 加密
 * @param pass
 * @returns {*}
 */
function md5(pass) {
    var md = forge.md.md5.create();
    md.update(pass);
    var password = md.digest().toHex();
    return password;
}


/**
 * ID generator
 * @returns {string}
 */
function genId() {
    return 'ID-' + parseInt(Math.random() * 10000)
}
/**
 *  日期格式化
 * @param data
 * @returns {string}
 */
function formatDate(data) {
    var date = new Date(data);
    return date.getFullYear() + '-' + ((date.getMonth() + 1) > 9 ? (date.getMonth() + 1) : ('0' + (date.getMonth() + 1))) + '-' + (date.getDate() > 9 ? date.getDate() : ('0' + date.getDate()));
}
/**
 * 日期时间格式化
 * @param data
 * @returns {string}
 */
function formatTime(data) {
    var date = new Date(data);
    return date.getFullYear() + '-' + ((date.getMonth() + 1) > 9 ? (date.getMonth() + 1) : ('0' + (date.getMonth() + 1))) + '-' +
        (date.getDate() > 9 ? date.getDate() : ('0' + date.getDate())) + ' ' +
        (date.getHours() > 9 ? date.getHours() : ('0' + date.getHours())) + ':' +
        (date.getMinutes() > 9 ? date.getMinutes() : ('0' + date.getMinutes())) + ':' +
        (date.getSeconds() > 9 ? date.getSeconds() : ('0' + date.getSeconds()));
}
/**
 * 设置表单数据
 * @param formData
 * @param data
 * @returns {*}
 */
function setFormData(formData, data) {
    formData.map((item, index) => {
        if (data[item.name]) {
            formData[index].val = data[item.name];
        }else if (data[item.name]) {
            formData[index].val = data[item.name];
        }
    });
    return formData;
}
export {assign, genId,setFormData, formatDate, formatTime, jsonToQueryStr, Icon,Feather, Foundation, md5};
export * from './env';